﻿
@{
    Layout = "~/Views/Shared/_MobileLayout.cshtml";
    ViewBag.Title = "核对订单";
    var comboList = ViewBag.ComboList as List<LPY.LeHealth.DTO.Cart>;
}

@section Header{
    <link href="~/Asset/stepwizard.css" rel="stylesheet" />
}

<div class="stepwizard">
    <div class="stepwizard-row">
        <div class="stepwizard-step">
            <button type="button" class="btn btn-default btn-circle">1</button>
            <p><strong>购物车</strong></p>
        </div>
        <div class="stepwizard-step">
            <button type="button" class="btn btn-primary btn-circle">2</button>
            <p>核对订单</p>
        </div>
        <div class="stepwizard-step">
            <button type="button" class="btn btn-default btn-circle">3</button>
            <p>提交订单</p>
        </div>
    </div>
</div>

<ul class="list-group">
    <li class="list-group-item list-group-item-info">
        <span class="fa fa-info"></span> <strong>填写订单人信息</strong>
    </li>
    <li class="list-group-item">
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">姓名</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="name" placeholder="请输入姓名">
            </div>
        </div>
        <div class="form-group">
            <label for="phone" class="col-sm-2 control-label">手机号码</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="phone" placeholder="请输入手机号">
            </div>
        </div>
        <div class="form-group">
            <label for="code" class="col-sm-2 control-label">验证码</label>
            <div class="col-sm-10">
                <input type="text" class="form-control" id="code" placeholder="请输入验证码">
            </div>
        </div>
        <div id="msgNo" class="alert alert-danger" role="alert"></div>
        <div class="row" style="text-align:center;">
            <button id="getCode" type="button" class="btn btn-warning col-sm-3">获取验证码</button>
        </div>
        <div class="form-group">
            <label for="name" class="col-sm-2 control-label">性别</label>
            <div class="col-sm-10">
                <input type="radio" name="gender" value="0" checked /><span>男</span>
                <input type="radio" name="gender" value="1" /><span>女</span>
            </div>
        </div>
    </li>

    <li class="list-group-item list-group-item-info">
        <strong>支付方式</strong>
    </li>
    <li class="list-group-item">
        在线支付：温馨提示： 用户可以选择支付宝、网银等网络支付方式。
    </li>
    <li class="list-group-item list-group-item-info">
        <strong>可用优惠券（1张）</strong>
    </li>
    <li class="list-group-item">
        <div class="form-group">
            <label class="col-sm-2 control-label">每笔订单限使用1张</label>
            @*<div class="col-sm-5">
                <input type="text" class="form-control" id="phone" placeholder="请输入优惠券号">
            </div>*@
            <ul style="list-style:none;padding:0;">
                <li><input type="radio" name="couponid" value="1" checked> 首单8折</li>
                <li><input type="radio" name="couponid" value="2"> 满100减50</li>
                <li><input type="radio" name="couponid" value="3"> 500元优惠券【131231】</li>
            </ul>
        </div>
    </li>
    <li class="list-group-item list-group-item-info">
        <strong>套餐信息</strong>
    </li>
    <li class="list-group-item">
        @{
        decimal total=0;
        for (int i = 0; i < comboList.Count; i++)
        {
            {total = total + comboList[i].Combo.Price*comboList[i].Count;}
                      
            <div class="row">
                <div class="col-xs-4">
                    <a href="@Url.Action("ComboDetail", "Mobile", new { id = comboList[i].ComboId })">
                        <img class="img-rounded pull-left img-responsive" src="/Asset/tijian.png">
                    </a>
                </div>
                <div class="col-xs-8">
                    <p>
                        <strong><a title="@comboList[i].Combo.Name" href="@Url.Action("ComboDetail", "Mobile", new { id = comboList[i].ComboId })">@comboList[i].Combo.Name</a></strong>
                    </p>
                    <p class="priceinfo">
                        <b>¥<strong>@Math.Round(comboList[i].Combo.Price)</strong></b>
                        @*<s>原价：¥@Math.Round(comboList[i].Price)</s>*@
                    </p>
                </div>
            </div>
        }
        }

       
        @*<p>应付总额：<span style="color:red;font-weight:bold;">888</span></p>*@
    </li>
    <li class="list-group-item list-group-item-warning">
        <p style="text-align:right;font-weight:bold;">订单总额：<span style="color:red;">@Math.Round(total, 2)</span></p>
    </li>
</ul>
<a href="#" id="submit" class="btn btn-info btn-block">提交 <span class="glyphicon glyphicon-circle-arrow-right"></span></a>

@section Footer{
    <script type="text/javascript">
        $(function () {
            //获取验证码
            var msgNo = $("#msgNo");
            msgNo.hide();
            $("#getCode").click(function () {
                msgNo.hide();

                var phone = $("#phone").val();
                if (phone != null && phone.length > 0) {
                    $.ajax({
                        url: '@Url.Action("GetSecurityCode", "Mobile")',
                        type: 'post',
                        data: { phone: phone },
                        success: function (data) {
                            if (data.Code == 1) {
                                $("#code").val(data.Data);
                            }
                        }
                    });
                }
                else {
                    msgNo.html("请输入手机号码！");
                    msgNo.show();
                }
            });

            $("#submit").click(function () {
                var name =$("#name").val();
                var phone=$("#phone").val();
                var code = $("#code").val();
                var gender = $("input[name='gender']:checked").val();
                var couponid = $("input[name='couponid']:checked").val();

                $.ajax({
                    url: '@Url.Action("AddOrder", "Mobile")',
                    type: 'post',
                    data: { name: name, phone: phone, code: code, gender: gender, couponid: couponid,paytype:0},
                    success: function (data) {
                        if(data.Code==1)
                        {
                            window.location.href = data.Data;
                        }
                        else
                        {
                            alert(data.Msg);
                        }
                    }
                });
            });
        });
    </script>
}